#ifndef __ENGINE_CLIENT_REQUEST_included
#define __ENGINE_CLIENT_REQUEST_included

#include "../engine/Request.h"
#include "../port/System.h"
#include "Connection.h"

using namespace Engine;

class CRequestAction {

public :
	virtual void DoRequest(CRequest& request, CResponse& response) = 0;
};

typedef boost::shared_ptr<CRequestAction> RequestActionRef;

class CClientRequest : public CRequest {

protected :

	boost::shared_ptr<CConnection> mConnection;

public :

	CClientRequest(string& cmd) : CRequest(cmd)
	{
		AddPropertie(string(PACKAGE_PROP_DEVICE_TYPE), string("PC;") + Util::CSystem::GetHostName());
	}

	CClientRequest(string& cmd, boost::asio::streambuf& data) : CRequest(cmd, data)
	{ }

	CClientRequest(string& cmd, boost::shared_ptr<std::istream> is) : CRequest(cmd, is)
	{ }

	void SetConnection(boost::shared_ptr<CConnection> c) {
		mConnection = c;
	}

	virtual void Response(int status) {
		boost::shared_ptr<CResponse> resp = InitResponse();
		resp->SetStatus(status);
		mConnection->SendResponse(resp);
	}
};

#endif //__ENGINE_CLIENT_REQUEST_included